import { useFormStatus } from "react-dom";
async function submitForm() {
  await new Promise((res) => setTimeout(res, 1000));
}

function Submit() {
  const stas = useFormStatus();
  console.log(stas);
  return (
    <button type="submit" disabled={stas.pending}>
      {stas.pending ? "提交中……" : "提交"}
    </button>
  );
}

export default function UseFormStatus() {
  return (
    <form action={submitForm}>
      <Submit />
    </form>
  );
}
